package com.yisu.expressway.ui.recyclerview;

import android.content.Context;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;

/**
 * Created by will on 16/3/15.
 */
public class LinearLayoutManagerWrapper  extends LinearLayoutManager {
    private static final String TAG = "LinearLayoutManagerWrapper";
    public LinearLayoutManagerWrapper(final Context context) {
        super(context);
    }

    public LinearLayoutManagerWrapper(Context context, int orientation, boolean reverseLayout) {
        super(context, orientation, reverseLayout);
    }

    @Override
    public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
        try {
            return super.scrollVerticallyBy(dy, recycler, state);
        }catch (IndexOutOfBoundsException ex){

        }
        return 0;
    }

    @Override
    public void onInitializeAccessibilityNodeInfo(RecyclerView.Recycler recycler, RecyclerView.State state, AccessibilityNodeInfoCompat info) {
        try {
            super.onInitializeAccessibilityNodeInfo(recycler, state, info);
        }catch (final NullPointerException e){

        }
    }

    @Override
    public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View host, AccessibilityNodeInfoCompat info) {
        try {
            super.onInitializeAccessibilityNodeInfoForItem(recycler, state, host, info);
        }catch (final NullPointerException e){

        }
    }

    @Override
    public void onInitializeAccessibilityEvent(final AccessibilityEvent event) {
        try {
            super.onInitializeAccessibilityEvent(event);
        } catch (final NullPointerException e) {
//            Log.e(TAG, "NullPointerException in onInitializeAccessibilityEvent(" + event +
//                    ')', e);
        }
    }
    @Override
    public void onInitializeAccessibilityEvent(final RecyclerView.Recycler recycler,
                                               final RecyclerView.State state, final AccessibilityEvent event) {
        try {
            super.onInitializeAccessibilityEvent(recycler, state, event);
        } catch (final NullPointerException e) {
//            Log.e(TAG, "NullPointerException in onInitializeAccessibilityEvent(" + recycler +
//                    ", " + state + ", " + event + ')', e);
        }
    }
}
